home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / SCHEME / GNU / SCM4E1 / !Scm / slib / Template < prev    next >
Text File  |  1994-03-04  |  7KB  |  239 lines

  1. ;;;; Template for configuration of *features* for Scheme    -*-scheme-*-
  2. ;;; Copyright (C) 1991, 1992, 1993 Aubrey Jaffer.
  3.  
  4. ;Permission to copy this software, to redistribute it, and to use it
  5. ;for any purpose is granted, subject to the following restrictions and
  6. ;understandings.
  7.  
  8. ;1.  Any copy made of this software must include this copyright notice
  9. ;in full.
  10.  
  11. ;2.  I have made no warrantee or representation that the operation of
  12. ;this software will be error-free, and I am under no obligation to
  13. ;provide any services, by way of maintenance, update, or otherwise.
  14.  
  15. ;3.  In conjunction with products arising from the use of this
  16. ;material, there shall be no use of my name in any advertising,
  17. ;promotional, or sales literature without prior written consent in
  18. ;each case.
  19.  
  20. ;;; (software-type) should be set to the generic operating system type.
  21. ;;; UNIX, VMS, MACOS, AMIGA and MSDOS are supported.
  22.  
  23. (define (software-type) 'UNIX)
  24.  
  25. ;;; *FEATURES* should be set to a list of symbols describing features
  26. ;;; of this implementation.  Suggestions for features are:
  27.  
  28. (define *features*
  29.       '(
  30.     source                ;can load scheme source files
  31.                     ;(slib:load-source "filename")
  32. ;    compiled            ;can load compiled files
  33.                     ;(slib:load-compiled "filename")
  34. ;    rev4-report            ;conforms to
  35. ;    rev3-report            ;conforms to
  36. ;    ieee-p1178            ;conforms to
  37. ;    sicp                ;runs code from Structure and
  38.                     ;Interpretation of Computer
  39.                     ;Programs by Abelson and Sussman.
  40. ;    rev4-optional-procedures    ;LIST-TAIL, STRING->LIST,
  41.                     ;LIST->STRING, STRING-COPY,
  42.                     ;STRING-FILL!, LIST->VECTOR,
  43.                     ;VECTOR->LIST, and VECTOR-FILL!
  44. ;    rev3-procedures            ;LAST-PAIR, T, and NIL
  45. ;    rev2-procedures            ;SUBSTRING-MOVE-LEFT!,
  46.                     ;SUBSTRING-MOVE-RIGHT!,
  47.                     ;SUBSTRING-FILL!,
  48.                     ;STRING-NULL?, APPEND!, 1+,
  49.                     ;-1+, <?, <=?, =?, >?, >=?
  50. ;    multiarg/and-            ;/ and - can take more than 2 args.
  51. ;    multiarg-apply            ;APPLY can take more than 2 args.
  52. ;    rationalize
  53. ;    delay                ;has DELAY and FORCE
  54. ;    with-file            ;has WITH-INPUT-FROM-FILE and
  55.                     ;WITH-OUTPUT-FROM-FILE
  56. ;    string-port            ;has CALL-WITH-INPUT-STRING and
  57.                     ;CALL-WITH-OUTPUT-STRING
  58. ;    transcript            ;TRANSCRIPT-ON and TRANSCRIPT-OFF
  59. ;    char-ready?
  60. ;    macro                ;has R4RS high level macros
  61. ;    defmacro            ;has Common Lisp DEFMACRO
  62. ;    eval                ;SLIB:EVAL is single argument eval
  63. ;    record                ;has user defined data structures
  64. ;    values                ;proposed multiple values
  65. ;    dynamic-wind            ;proposed dynamic-wind
  66. ;    ieee-floating-point        ;conforms to
  67.     full-continuation        ;can return multiple times
  68. ;    object-hash            ;has OBJECT-HASH
  69.  
  70. ;    sort
  71. ;    queue                ;queues
  72. ;    pretty-print
  73. ;    object->string
  74. ;    format
  75. ;    compiler            ;has (COMPILER)
  76. ;    ed                ;(ED) is editor
  77. ;    system                ;posix (system <string>)
  78.     getenv                ;posix (getenv <string>)
  79. ;    program-arguments        ;returns list of strings (argv)
  80. ;    Xwindows            ;X support
  81. ;    curses                ;screen management package
  82. ;    termcap                ;terminal description package
  83. ;    terminfo            ;sysV terminal description
  84.     ))
  85.  
  86. ;;; (OUTPUT-PORT-WIDTH <port>)
  87. (define (output-port-width . arg) 79)
  88.  
  89. ;;; (OUTPUT-PORT-HEIGHT <port>)
  90. (define (output-port-height . arg) 24)
  91.  
  92. ;;; (CURRENT-ERROR-PORT)
  93. (define current-error-port
  94.   (let ((port (current-output-port)))
  95.     (lambda () port)))
  96.  
  97. ;;; (TMPNAM) makes a temporary file name.
  98. (define tmpnam (let ((cntr 100))
  99.          (lambda () (set! cntr (+ 1 cntr))
  100.              (string-append "slib_" (number->string cntr)))))
  101.  
  102. ;;; (FILE-EXISTS? <string>)
  103. (define (file-exists? f) #f)
  104.  
  105. ;;; (DELETE-FILE <string>)
  106. (define (delete-file f) #f)
  107.  
  108. ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
  109. ;;; use this definition if your system doesn't have such a procedure.
  110. (define (force-output . arg) #t)
  111.  
  112. ;;; CALL-WITH-INPUT-STRING and CALL-WITH-OUTPUT-STRING are the string
  113. ;;; port versions of CALL-WITH-*PUT-FILE.
  114.  
  115. ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
  116. ;;; be returned by CHAR->INTEGER.
  117. (define char-code-limit 256)
  118.  
  119. ;;; MOST-POSITIVE-FIXNUM is used in modular.scm
  120. (define most-positive-fixnum #x0FFFFFFF)
  121.  
  122. ;;; If your implementation provides eval SLIB:EVAL is single argument
  123. ;;; eval using the top-level (user) environment.
  124. ;(define slib:eval eval)
  125.  
  126. ;;; If your implementation provides R4RS macros:
  127. ;(define macro:eval slib:eval)
  128. ;(define macro:load load)
  129.  
  130. (define *defmacros*
  131.   (list (cons 'defmacro
  132.           (lambda (name parms . body)
  133.         `(set! *defmacros* (cons (cons ',name (lambda ,parms ,@body))
  134.                       *defmacros*))))))
  135. (define (defmacro? m) (and (assq m *defmacros*) #t))
  136.  
  137. (define (macroexpand-1 e)
  138.   (if (pair? e) (let ((a (car e)))
  139.           (cond ((symbol? a) (set! a (assq a *defmacros*))
  140.                      (if a (apply (cdr a) (cdr e)) e))
  141.             (else e)))
  142.       e))
  143.  
  144. (define (macroexpand e)
  145.   (if (pair? e) (let ((a (car e)))
  146.           (cond ((symbol? a)
  147.              (set! a (assq a *defmacros*))
  148.              (if a (macroexpand (apply (cdr a) (cdr e))) e))
  149.             (else e)))
  150.       e))
  151.  
  152. (define gentemp
  153.   (let ((*gensym-counter* -1))
  154.     (lambda ()
  155.       (set! *gensym-counter* (+ *gensym-counter* 1))
  156.       (string->symbol
  157.        (string-append "slib:G" (number->string *gensym-counter*))))))
  158.  
  159. (define base:eval slib:eval)
  160. (define (defmacro:eval x) (base:eval (defmacro:expand* x)))
  161. (define (defmacro:expand* x)
  162.   (require 'defmacroexpand) (apply defmacro:expand* x '()))
  163.  
  164. (define (defmacro:load <pathname>)
  165.   (call-with-input-file <pathname>
  166.     (lambda (port)
  167.       (let ((old-load-pathname *load-pathname*))
  168.     (set! *load-pathname* <pathname>)
  169.     (do ((o (read port) (read port)))
  170.         ((eof-object? o))
  171.       (defmacro:eval o))
  172.     (set! *load-pathname* old-load-pathname)))))
  173.  
  174. ;;; define an error procedure for the library
  175. ;(define slib:error error)
  176.  
  177. ;;; define these as appropriate for your system.
  178. (define slib:tab (integer->char 9))
  179. (define slib:form-feed (integer->char 12))
  180.  
  181. ;;; Define these if your implementation's syntax can support it and if
  182. ;;; they are not already defined.
  183.  
  184. ;(define (1+ n) (+ n 1))
  185. ;(define (-1+ n) (+ n -1))
  186. ;(define 1- -1+)
  187.  
  188. ;;; (implementation-vicinity) should be defined to be the pathname of
  189. ;;; the directory where any auxillary files to your Scheme
  190. ;;; implementation reside.
  191.  
  192. (define (implementation-vicinity)
  193.   (case (software-type)
  194.     ((UNIX)     "/usr/local/src/scheme/")
  195.     ((VMS)    "scheme$src:")
  196.     ((MSDOS)    "C:\\scheme\\")))
  197.  
  198. ;;; (library-vicinity) should be defined to be the pathname of the
  199. ;;; directory where files of Scheme library functions reside.
  200.  
  201. (define library-vicinity
  202.   (let ((library-path
  203.      (or (and (memq 'getenv *features*)
  204.           (getenv "SCHEME_LIBRARY_PATH"))
  205. ;;; Uses this path if your scheme does not support GETENV.
  206.          (case (software-type)
  207.            ((UNIX) "/usr/local/lib/slib/")
  208.            ((VMS) "lib$scheme:")
  209.            ((MSDOS) "C:\\SLIB\\")
  210.            (else "")))))
  211.  
  212.     (lambda () library-path)))
  213.  
  214. (define in-vicinity string-append)
  215.  
  216. ;;; Here for backward compatability
  217. (define scheme-file-suffix
  218.   (let ((suffix (case (software-type)
  219.           ((NOSVE) "_scm")
  220.           (else ".scm"))))
  221.     (lambda () suffix)))
  222.  
  223. ;;; (SLIB:LOAD-SOURCE "foo") should load "foo.scm" or with whatever
  224. ;;; suffix all the module files in SLIB have.  See feature 'SOURCE.
  225.  
  226. (define (slib:load-source f) (load (string-append f ".scm")))
  227.  
  228. ;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced
  229. ;;; by compiling "foo.scm" if this implementation can compile files.
  230. ;;; See feature 'COMPILED.
  231.  
  232. (define slib:load-compiled load)
  233.  
  234. ;;; At this point SLIB:LOAD must be able to load SLIB files.
  235.  
  236. (define slib:load slib:load-source)
  237.  
  238. (slib:load (in-vicinity (library-vicinity) "require"))
  239.